package com.ruoyi.supplier.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.supplier.domain.TbReportOutFlow;
import com.ruoyi.supplier.service.ITbReportOutFlowService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 每日营业进账流水Controller
 * 
 * @author oliver.li
 * @date 2021-08-14
 */
@RestController
@RequestMapping("/supplier/reportOutFlow")
public class TbReportOutFlowController extends BaseController
{
    @Autowired
    private ITbReportOutFlowService tbReportOutFlowService;

    /**
     * 查询每日营业进账流水列表
     */
    @PreAuthorize("@ss.hasPermi('supplier:reportOutFlow:list')")
    @GetMapping("/list")
    public TableDataInfo list(TbReportOutFlow tbReportOutFlow)
    {
        startPage();
        List<TbReportOutFlow> list = tbReportOutFlowService.selectTbReportOutFlowList(tbReportOutFlow);
        return getDataTable(list);
    }

    /**
     * 导出每日营业进账流水列表
     */
    @PreAuthorize("@ss.hasPermi('supplier:reportOutFlow:export')")
    @Log(title = "每日营业进账流水", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TbReportOutFlow tbReportOutFlow)
    {
        List<TbReportOutFlow> list = tbReportOutFlowService.selectTbReportOutFlowList(tbReportOutFlow);
        ExcelUtil<TbReportOutFlow> util = new ExcelUtil<TbReportOutFlow>(TbReportOutFlow.class);
        return util.exportExcel(list, "每日营业进账流水数据");
    }

    /**
     * 获取每日营业进账流水详细信息
     */
    @PreAuthorize("@ss.hasPermi('supplier:reportOutFlow:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tbReportOutFlowService.selectTbReportOutFlowById(id));
    }

    /**
     * 新增每日营业进账流水
     */
    @PreAuthorize("@ss.hasPermi('supplier:reportOutFlow:add')")
    @Log(title = "每日营业进账流水", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbReportOutFlow tbReportOutFlow)
    {
        return toAjax(tbReportOutFlowService.insertTbReportOutFlow(tbReportOutFlow));
    }

    /**
     * 修改每日营业进账流水
     */
    @PreAuthorize("@ss.hasPermi('supplier:reportOutFlow:edit')")
    @Log(title = "每日营业进账流水", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbReportOutFlow tbReportOutFlow)
    {
        return toAjax(tbReportOutFlowService.updateTbReportOutFlow(tbReportOutFlow));
    }

    /**
     * 删除每日营业进账流水
     */
    @PreAuthorize("@ss.hasPermi('supplier:reportOutFlow:remove')")
    @Log(title = "每日营业进账流水", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tbReportOutFlowService.deleteTbReportOutFlowByIds(ids));
    }
}
